package aps

import glory.xxd.Utils
import org.json.JSONObject

/**
 * 日检周检界面按返回键
 */
class CheckReturnController {

    /**
     * <Request>
     *   <Header>
     *    <TRANSACTIONID>8c3f8423-51ef-4a23-bb38-a26aba909db5</TRANSACTIONID>
     *    <MESSAGENAME>CheckReturn</MESSAGENAME>
     *    <USERNAME>EAP</USERNAME>
     *  </Header>
     *  <Body class="Body">
     *    <EQPID>1FS05</EQPID>
     *    <OPID>G2976</OPID>
     *    <CHECKTYPE>DAY/WEEKS</CHECKTYPE> 日检/周检
     *    <TOREQUEST>A/B</TOREQUEST>  A-->提交 B-->确认提交
     *  </Body>
     * </Request>
     *
     * */
    def commentService
    def index() {
        def EQPID = params.EQPID ?: ""
        def OPID = params.OPID?:""
        def CHECKTYPE = params.CHECKTYPE ?: ""
        def TOREQUEST = params.TOREQUEST ?: ""

        def body =JSONObject.newInstance()
        body.put("EQPID",EQPID)
        body.put("OPID",OPID)
        body.put("CHECKTYPE",CHECKTYPE)
        body.put("TOREQUEST",TOREQUEST)

        String logUUID = Utils.getUUID();
        def header = JSONObject.newInstance()
        header.put("MESSAGENAME","CheckReturn")
        header.put("TRANSACTIONID",logUUID)
        header.put("USERNAME","PDA")

        def jsonAll = [Header:header,Body:body] //JSONObject.newInstance()

        def jsonRequest = JSONObject.newInstance()
        jsonRequest.put("Request",jsonAll)

        def json = commentService.getJsonByJsonForTopic2Queue(logUUID, jsonRequest)

        render json
    }
}
